import { Pipe, PipeTransform } from '@angular/core';

/**
 * 分成方式 1激活可赚 2注册可赚 3充值分成 4消费分成
 */
export const divideSharingStatusArrs = [
  {value: 1, label: '激活可赚'},
  {value: 2, label: '注册可赚'},
  {value: 3, label: '充值分成'},
  {value: 4, label: '消费分成'}
];
@Pipe({ name: 'sharingStatus' })
export class SharingStatusPipe implements PipeTransform {
  transform(value: any, exponent?: number): any {
    switch(value) {
      case 1:
        return '激活可赚';
      case 2:
        return '注册可赚';
      case 3:
        return '充值分成';
      case 4:
        return '消费分成';
      default:
        return '';
    }
  }
}

/**
 * 安装方式 1直接安装 2浏览器安装 3微信扫码
 */
export const divideInstallStatusArrs = [
  {value: 1, label: '直接安装'},
  {value: 2, label: '浏览器安装'},
  {value: 3, label: '微信扫码'}
];
@Pipe({ name: 'installStatus' })
export class InstallStatusPipe implements PipeTransform {
  transform(value: any, exponent?: number): any {
    switch(value) {
      case 1:
        return '直接安装';
      case 2:
        return '浏览器安装';
      case 3:
        return '微信扫码';
      default:
        return '-';
    }
  }
}

/**
 * 用户类型 0通用 1个人 2门店商户用户 
 */
@Pipe({ name: 'userTypeStatus' })
export class UserTypeStatusPipe implements PipeTransform {
  transform(value: any, exponent?: number): any {
    switch(value) {
      case 0:
        return '通用';
      case 1:
        return 'C端';
      case 2:
        return 'B端';
      default:
        return '-';
    }
  }
}

/**
 * 推广渠道 0通用 1爱思PC端 2爱思移动端
 */
@Pipe({ name: 'promotionStatus' })
export class PromotionStatusPipe implements PipeTransform {
  transform(value: any, exponent?: number): any {
    switch(value) {
      case 0:
        return '通用';
      case 1:
        return '爱思PC端';
      case 2:
        return '爱思移动端';
      default:
        return '-';
    }
  }
}

/**
 * 审核状态（开发者）
 * 0-待完善资料，1-待审核，2-审核通过，3-审核失败
 */
export const divideDeveloperStatusArrs = [
  {value: 0, label: '待完善', color: '#606266'},
  {value: 1, label: '待审核', color: '#409EFF'},
  {value: 2, label: '审核通过', color: '#67C23A'},
  {value: 3, label: '审核不通过', color: '#F56C6C'}
];
@Pipe({
  name: 'divideDeveloperStatus'
})
export class DivideDeveloperStatusPipe implements PipeTransform {
  transform(value: any, type: string): any {
    let tmpObj: any = divideDeveloperStatusArrs.find(item => item.value === value);

    if (type === 'color') {
      return tmpObj?.color || '';
    } else {
      return tmpObj?.label || '-';
    }
  }
}

/**
 * 审核状态（应用）
 * 0-默认，1-待审核，2-审核通过，3-审核失败
 */
export const divideAppStatusArrs = [
  // {value: 0, label: '待完善', color: '#606266'},
  {value: 1, label: '待审核', color: '#409EFF'},
  {value: 2, label: '审核通过', color: '#67C23A'},
  {value: 3, label: '审核不通过', color: '#F56C6C'}
];
@Pipe({
  name: 'divideAppStatus'
})
export class DivideAppStatusPipe implements PipeTransform {
  transform(value: any, type: string): any {
    let tmpObj: any = divideAppStatusArrs.find(item => item.value === value);

    if (type === 'color') {
      return tmpObj?.color || '';
    } else {
      return tmpObj?.label || '-';
    }
  }
}

/**
 * 充值记录 状态
 * 1：等待充值 2：充值成功
 */
export const divideRechargeStatusArrs = [
  {value: 1, label: '等待充值', color: '#E6A23C'},
  {value: 2, label: '充值成功', color: '#67C23A'}
];

@Pipe({
  name: 'divideRechargeStatus'
})
export class DivideRechargeStatusPipe implements PipeTransform {
  transform(value: any, type: string) {
    let tempObjs: any = divideRechargeStatusArrs.find(item => item.value === value);

    if (type === 'color') {
      return tempObjs?.color || '';
    } else {
      return tempObjs?.label || '-';
    }
  }
}

/**
 * 消费记录 状态
 * 1：等待消费 2：消费成功
 */
export const divideConsumeStatusArrs = [
  {value: 1, label: '等待消费', color: '#E6A23C'},
  {value: 2, label: '消费成功', color: '#67C23A'}
];

@Pipe({
  name: 'divideConsumeStatus'
})
export class DivideConsumeStatusPipe implements PipeTransform {
  transform(value: any, type: string) {
    let tempObjs: any = divideConsumeStatusArrs.find(item => item.value === value);

    if (type === 'color') {
      return tempObjs?.color || '';
    } else {
      return tempObjs?.label || '-';
    }
  }
}

/**
 * 充值 | 消费记录 支付方式
 * 0. 系统赠与 1.支付宝 2.微信 3.银联 4.活动奖励
 */
export const dividePayTypeArrs = [
  {value: 0, label: '系统赠与', color: '#909399'},
  {value: 1, label: '支付宝', color: '#409EFF'},
  {value: 2, label: '微信', color: '#67C23A'},
  {value: 3, label: '银联', color: '#E6A23C'},
  {value: 4, label: '活动奖励', color: '#F56C6C'}
];

@Pipe({
  name: 'dividePayType'
})
export class DividePayTypePipe implements PipeTransform {
  transform(value: any, type: string) {
    let tempObjs: any = dividePayTypeArrs.find(item => item.value === value);

    if (type === 'color') {
      return tempObjs?.color || '';
    } else {
      return tempObjs?.label || '-';
    }
  }
}

/**
 * 游戏推广 | 热门搜索
 * 0.未开始 1.进行中 2.已删除 3.已结束
 */
export const gameHotTypeArrs = [
  {value: 0, label: '未开始', color: '#909399'},
  {value: 1, label: '进行中', color: '#67C23A'},
  // {value: 2, label: '已删除', color: '#F56C6C'},
  {value: 3, label: '已结束', color: '#F56C6C'}
];

@Pipe({
  name: 'gameHotType'
})
export class GameHotTypePipe implements PipeTransform {
  transform(value: any, type: string) {
    let tempObjs: any = gameHotTypeArrs.find(item => item.value === value);

    if (type === 'color') {
      return tempObjs?.color || '';
    } else {
      return tempObjs?.label || '-';
    }
  }
}

/**
 * 游戏推广 | 活动公告
 * 0 待自动发送 1 已发送 2 已撤回
 */
export const gameActNoticeStatusArrs = [
  {value: 0, label: '待发送', color: '#909399'},
  {value: 1, label: '已发送', color: '#67C23A'},
  {value: 2, label: '已撤回', color: '#F56C6C'}
];

@Pipe({
  name: 'gameActNoticeStatus'
})
export class GameActNoticeStatusPipe implements PipeTransform {
  transform(value: any, type: string) {
    let tempObjs: any = gameActNoticeStatusArrs.find(item => item.value === value);

    if (type === 'color') {
      return tempObjs?.color || '';
    } else {
      return tempObjs?.label || '-';
    }
  }
}

/**
 * 游戏推广 | 游戏banner
 * 0 未开始 1 进行中 3 已结束
 */
export const gameBannerStatusArrs = [
  {value: 0, label: '未开始', color: '#909399'},
  {value: 1, label: '进行中', color: '#67C23A'},
  {value: 3, label: '已结束', color: '#F56C6C'}
];

@Pipe({
  name: 'gameBannerStatus'
})
export class GameBannerStatusPipe implements PipeTransform {
  transform(value: any, type: string) {
    let tempObjs: any = gameBannerStatusArrs.find(item => item.value === value);

    if (type === 'color') {
      return tempObjs?.color || '';
    } else {
      return tempObjs?.label || '-';
    }
  }
}